package com.likersai.opon.service.impl;

import com.likersai.opon.pojo.entity.ToxicSaying;
import com.likersai.opon.dao.ToxicSayingMapper;
import com.likersai.opon.pojo.vo.req.ToxicSayingReq;
import com.likersai.opon.pojo.vo.rsp.ToxicSayingRsp;
import com.likersai.opon.service.ToxicSayingService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * 毒鸡汤服务类
 *
 * @author sun.ye
 * @since 2021-01-13 22:25
 */
@Service
public class ToxicSayingImpl implements ToxicSayingService {

    @Resource
    private ToxicSayingMapper toxicSayingMapper;


    @Override
    public ToxicSayingRsp queryRandomOne() {
        ToxicSaying toxicSaying = toxicSayingMapper.selectRandomOne();
        return ToxicSayingRsp.from(toxicSaying);
    }

    @Override
    public ToxicSayingRsp saveOne(ToxicSayingReq record) {
        ToxicSaying entity = record.toEntity();
        toxicSayingMapper.insertToxicSaying(entity);
        return ToxicSayingRsp.from(entity);
    }
    
    @Override
    public ToxicSayingRsp modifyToxicSaying (ToxicSayingReq record) {
        ToxicSaying entity = record.toEntity();
        toxicSayingMapper.updateToxicSaying(entity);
        return ToxicSayingRsp.from(entity);
    }
}